Macromedia Flex Article

Learning Flex Basics (Part 2): Creating a Simple Calculator with Macromedia Flex


Table of Contents

  1. Introduction
  2. Building the Calculator
  3. Create the Application Object
  4. Add a Panel for the Calculator
  5. Add the Calculator Display
  6. Add a Grid to Lay Out the Buttons
  7. Add the Calculator Buttons
  8. Create the CalculatorController Class
  9. Add Properties to the Controller Class
  10. Add Controller Methods
  11. Instantiate the CalculatorController Class
  12. Complete Code Listing for calculator.mxml
  13. Complete Code Listing for CalculatorController.as
  14. Where to Go From Here

Add the Calculator Display

The Label element displays a single line of text. It has a number of properties; here, you will use the following properties:

  • id: a unique identifier used to reference this instance in an event handler
  • width: width of label in pixels
  • text: text to display
  • textAlign: horizontal alignment of text: left | right | center
  1. Inside the Panel block, add a Label with the properties as follows:

    <mx:Label id="calcDisplay" width="150" textAlign="right" />
    

Note: There is no text value in this tag because you will set the value with handler methods in the controller class; you build that functionality later in the tutorial.